package com.xiaoxiong.mami.dao.mapperImpl;

import com.xiaoxiong.mami.dao.daomain.OrderGoods;

import java.text.MessageFormat;
import java.util.List;
import java.util.Map;

/**
 * Created by Administrator on 2017/8/12.
 */
public class InsertListImpl {


    public String insertOrderGoodsList(Map map) {
        List<OrderGoods> orderGoodsList = (List<OrderGoods>) map.get("list");
        StringBuilder sb = new StringBuilder();
        sb.append("INSERT INTO order_goods ");
        sb.append("(orderid,goodstitle,goodsid,goodsprice,thumburl,total,createtime) VALUES ");
        MessageFormat mf = new MessageFormat("(#'{'list[{0}].orderId},#'{'list[{0}].goodsTitle},#'{'list[{0}].goodsId},#'{'list[{0}].goodsPrice}," +
                "#'{'list[{0}].thumbUrl},#'{'list[{0}].total},now())");
        for (int i = 0; i < orderGoodsList.size(); i++) {
            sb.append(mf.format(new Object[]{i}));
            if (i < orderGoodsList.size() - 1) {
                sb.append(",");
            }
        }
        return sb.toString();
    }


}
